require 'yaml'

module UnfuddleMyEmail
  # Configuration loads the given +path+ as a YAML file and enables
  # method-like access to configuration information.
  #
  # The expected format of the YAML file is:
  #
  #   configuration_key: configuration_value
  #   configuration_second_key: configuration_value
  #
  # etc.
  #
  # Example usage:
  #
  #   configuration = Configuration.new("path/to/yaml.yml")
  #   configuration.key # => value
  class Configuration
    attr_accessor :settings

    def initialize(path)
      @settings = YAML.load_file(path)
    end

    def method_missing(method_symbol, *args)
      @settings[method_symbol.to_s]
    end
  end
end
